<html>
<head>
    <title></title>
    <link rel="stylesheet" type="text/css" href="css/bootstrap.css">
</head>
<body>
    <button class="btn btn-primary btn-lg" id="openModal" data-toggle="modal" data-target="#myModal">
      Launch demo modal
    </button>

    <div class="modal fade" id="myModal">
      <div class="modal-dialog">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
            <h4 class="modal-title">Modal title</h4>
          </div>
          <div class="modal-body">
            <p>One fine body&hellip;</p>
            <div id="ajaxInsert"></div>
          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
            <button type="button" class="btn btn-primary">Save changes</button>
          </div>
        </div><!-- /.modal-content -->
      </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->


    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
    <script src="js/bootstrap.js"></script>
    <script>

    var loadedData = false;

    //target modal start button to load data before showing modal for first time
    $("#openModal").click(function(){
        if(loadedData == false){
            $.get( "dbTest.php", function( data ) {
                $("#ajaxInsert").html(data);
                console.log('data loaded');
                loadedData = true;
            });
        }
    });

    </script>
</body>
</html>